<?php

declare(strict_types=1);

namespace App\Controller\Cash\v1;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Contract\RequestInterface;
use Service\DeclareService\WayBillDeclareService;
use Service\OrderService\CashOrderService;
use Service\VenderClient\FacePlus\FacePlusApi;
/**
 * 登录控制器
 * @Controller(prefix="/cash/v1/test")
 */
class TestController extends AbstractController
{
    /**
     * 登录接口
     * @RequestMapping(path="test", methods="get")
     */
    public function testsms()
    {
        $key=[
            'api_key'=>'v9Z-GOm8Yel11Ji4SAfWbpbYwJ0ACYAA',
            'api_secret'=>'yk9JR76TzaFVXixOPSsnNTMUGW2209F3'
        ];
        
        $client = (new FacePlusApi($key));
        //人脸库详情
        $detail=$client->getFaceStorageDetail(['outer_id'=>'test001','face_tokens'=>'ae92c67ae82e4cd13e1b2d36ad5549ea']);
        return $detail;
         //添加人脸
//        $add=$client->addFace(['outer_id'=>'test001','face_tokens'=>'1983d3538e666ce70229587ff2c944bf']);
//        return $add;
        //更新人脸库
//        $update=$client->updateFaceStorage(['outer_id'=>'test001','display_name'=>'测试一号库','tags'=>'a1,b2']);
//        return $update;
        //人脸库列表
//        $getstorage=$client->getFaceStorageList([]);
//        return $getstorage;
        //创建人脸库
//        $createstorage=$client->createFaceStorage(['outer_id'=>'test001','display_name'=>'测试一号库','tags'=>'测试,一号']);
//        return $createstorage;
        //人脸检测
        $image1='http://image13.m1905.cn/mdb/uploadfile/2021/0218/thumb_1_168_230_20210218111140111244.jpg';
        $image2='https://pics7.baidu.com/feed/d1160924ab18972b9ef57062a6426a859c510ae1.jpeg';
        $content = file_get_contents($image2);
        $image_base64= base64_encode($content);
//        $createimage=  $client->faceCheck(['image_base64'=>$image_base64]);
//        return $createimage;
        $searchimage=  $client->search(['image_base64'=>$image_base64,'outer_id'=>'test001']);
        return $searchimage;
        $json = '{"cid":23,"mn_sid":846,"order_id":67549,"order_sn":"202303231652128460158","order_report_id":1}';
        $data = json_decode($json,true);
        return WayBillDeclareService::instance()->wayBillDeclare($data);
    }

    /**
     * 组合装改价获取新的税费
     * @RequestMapping(path="test", methods="post")
     */
    public function test(RequestInterface $request){
        $body = $request->getParsedBody();
        return CashOrderService::instance()->test($body);
    }
}